class Solution {
public:
    int minimumOperationsToMakeKPeriodic(string word, int k)
    {
        int n = word.size();
        int m = n / k;
        int mx = 0;
        unordered_map<string, int> hash;
        for (int i = 0; i < n; i += k)
        {
            string s(word.begin() + i, word.begin() + i + k);
            hash[s]++;
            mx = max(mx, hash[s]);
        }
        return m - mx;
    }
};